# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=openvpn3
pkgver=3.8.5
pkgrel=0
pkgdesc="C++ class library that implements the functionality of an OpenVPN client"
url="https://github.com/OpenVPN/openvpn3"
arch="all !s390x" # broken tests due to endianness assumptions
license="AGPL-3.0-only"
depends_dev="lz4-dev asio-dev libcap-dev jsoncpp-dev xxhash-dev"
makedepends="cmake samurai gtest-dev $depends_dev"
subpackages="$pkgname-dev"
source="https://github.com/OpenVPN/openvpn3/archive/refs/tags/release/$pkgver/openvpn3-$pkgver.tar.gz
	unvendor.patch
	"
builddir="$srcdir/openvpn3-release-$pkgver"

build() {
	cmake -G Ninja -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=False \
		-DCMAKE_BUILD_TYPE=MinSizeRel
	cmake --build build
}

check() {
	cd build
	test/unittests/coreUnitTests \
		--gtest_filter=-buffer_ip.ipv6
}

package() {
	# no cmake install target
	install -Dm755 build/test/ovpncli/ovpncli -t "$pkgdir"/usr/bin
	mkdir "$pkgdir"/usr/include
	mv openvpn "$pkgdir"/usr/include
}

sha512sums="
01e750267857d8ae23b4da4460a1e515ebbfadc17e0ff8ad0513368f51c0cf53fc5a41a92422f04812161be2b2b2f3fbc793a72150a8c902af201c2ee9028025  openvpn3-3.8.5.tar.gz
8bd3e9c92734b75701f0845398e831086a8a6d1e7f595f3873e0b599604379a0f99f9764f9ba19a16eb6a63216875ae8607a50c8fc0145ddcf05934a2ba1fb91  unvendor.patch
"
